﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using eShop.Core;
namespace eShop.Services
{
    /// <summary>
    /// 少data层
    /// </summary>
    public class AdminProductDetails
    {
        #region 商品明细处理类


        /// <summary>
        /// 更新明细
        /// </summary>
        /// <param name="_detailInfo"></param>
        /// <returns></returns>
        public static int UpdateProductDetails(ProductDetailsInfo _detailInfo)
        {
            int ret = eShop.Core.BSPData.RDBS.UpdateProductDetails(_detailInfo);
            return ret;
        }

        public static void CreateProductDetails(ProductDetailsInfo _detailInfo)
        {
            int ret = eShop.Core.BSPData.RDBS.CreateProductDetails(_detailInfo);
            if (ret > 0)
            {

            }
        }




        public static DataTable AdminGetProductDetailsList(int pid)
        {
            return eShop.Core.BSPData.RDBS.GetProductDetailsList(pid);
        }

        public static DataTable AdminGetProductDetailsSelectList(int pageSize, int pageNumber, string condition)
        {
            return eShop.Core.BSPData.RDBS.AdminProductDetailsSelectList(pageSize, pageNumber, condition);
        }


        public static int DeleteProductDetailsId(int sid)
        {
            return eShop.Core.BSPData.RDBS.DeleteProductDetailsId(sid);
        }


        /// <summary>
        /// 获取单件信息明细
        /// </summary>
        /// <param name="sid"></param>
        /// <returns></returns>
        public static ProductDetailsInfo GetProductDetailsBysid(int sid)
        {
            ProductDetailsInfo info = null;
            IDataReader reader = eShop.Core.BSPData.RDBS.GetProductDetailsBysid(sid);
            if (reader.Read())
            {
                info = new ProductDetailsInfo();
                info.Sid = TypeHelper.ObjectToInt(reader["sid"]);
                info.Pid = TypeHelper.ObjectToInt(reader["pid"]);

                info.Vin = reader["vin"].ToString();
                info.Gde = reader["gde"].ToString();

                //自定义
                info.Conf1 = reader["conf1"].ToString();
                info.Conf2 = reader["conf2"].ToString();

                info.Conf3 = reader["conf3"].ToString();
                info.Conf4 = reader["conf4"].ToString();

                info.Conf5 = reader["conf5"].ToString();
                info.Conf6 = reader["conf6"].ToString();

                info.Oid = TypeHelper.ObjectToInt(reader["oid"]);

                info.Description = reader["description"].ToString();
            }
            return info;
        }



        #endregion

    }
}
